package ui.activity.mine.biz;

import Bean.GetBankcardBean;
import base.BaseBiz;
import base.BaseResp;
import coom.BaseSubscribe;
import coom.RetrofitHelp;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by chenjian on 19/2/26.
 * 1
 */

public class BankCardBiz extends BaseBiz {

    /**
     * 获取银行卡列表
     */
    public void getCardList(final Callback<GetBankcardBean.DataBean> callback) {
        com.add(RetrofitHelp.getSecretApi().cardList()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscribe<BaseResp<GetBankcardBean.DataBean>>() {

                    @Override
                    public void onSuccess(Object obj) {
                        callback.onSuccess((GetBankcardBean.DataBean) obj);
                    }

                    @Override
                    public void onFailure(Object obj) {
                        callback.onFailure((GetBankcardBean.DataBean) obj);
                    }
                })
        );
    }

    /**
     * 删除银行卡
     */
    public void deleteCard(String url, final Callback<Object> callback) {
        com.add(RetrofitHelp.getSecretApi().delcar(url)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscribe<BaseResp<Object>>() {

                    @Override
                    public void onSuccess(Object obj) {
                        callback.onSuccess((Object) obj);
                    }

                    @Override
                    public void onFailure(Object obj) {
                        callback.onFailure((Object) obj);
                    }
                })
        );
    }
    /**
     * 修改默认银行卡
     */
    public void changeCard(String url, final Callback<Object> callback) {
        com.add(RetrofitHelp.getSecretApi().changeBankCard(url)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscribe<BaseResp<Object>>() {

                    @Override
                    public void onSuccess(Object obj) {
                        callback.onSuccess((Object) obj);
                    }

                    @Override
                    public void onFailure(Object obj) {
                        callback.onFailure((Object) obj);
                    }
                })
        );
    }



}
